const domain = "http://www.admin.com/api/";

export default class Https {

  request(url, data, method) {
    return new Promise((resolve, reject) => {
      wx.request({
        url: domain + url,
        data: data || {},
        method: method || 'GET',
        success: (result) => {
          var statusCode = result.statusCode
          if (statusCode !== 200) {
            wx.showToast({
              title: '网络异常，请重试',
              icon: "none",
              duration: 3000
            })
          }
          resolve(result.data)
        },
        fail: (res) => {
          wx.showToast({
            title: '网络异常，请重试',
            icon: "none"
          })
          reject(res)
        }
      })
    })
  }

}